# 使用栈的原理遍历目录
import os


def findAllFiles(path):
    stack = []
    stack.append(path)

    while len(stack) != 0:
        dirPath = stack.pop()

        filesList = os.listdir(dirPath)

        for fileName in filesList:
            fileAbsPath = os.path.join(dirPath, fileName)
            if os.path.isdir(fileAbsPath):
                print("这是一个目录：" + fileName)
                stack.append(fileAbsPath)
            else:
                print("这是一个普通文件：" + fileName)

findAllFiles(r"F:\back\python\stu-ptthon-qianfeng")


